package 编程能力入门1;

public class _04整数的各位积和之差 {
    public static int subtractProductAndSum(int n) {
        String nStr = Integer.toString(n);
        int cj = 1;
        int sum = 0;
        for (int i = nStr.length()-1; i >=0; i--) {
            cj *= nStr.charAt(i) - '0';
            sum += nStr.charAt(i) - '0';
        }

        return cj - sum;
    }

    public static void main(String[] args) {
        System.out.println(subtractProductAndSum(234));
        System.out.println(subtractProductAndSum(4421));
        System.out.println("我是测试代码......");
    }
}
